package com.nbgroup.controller;

import com.fasterxml.jackson.annotation.JsonFormat;
import com.nbgroup.pojo.common.Result;
import com.nbgroup.service.IndexService;
import io.swagger.annotations.Api;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.time.LocalDate;
import java.util.Set;


/**
 * 首页开发
 */
@RestController
@Slf4j
@Api(tags = "首页接口")
@RequestMapping("/index")
public class IndexController {
    @Autowired
    private IndexService indexService;

    @GetMapping("/{beginCreateTime}/{endCreateTime}")
    public Result getIndex(@PathVariable @JsonFormat LocalDate beginCreateTime,
                           @PathVariable @JsonFormat LocalDate endCreateTime) {

        return Result.success();
    }

    @GetMapping("/salesStatistic")
    public Result getSalesStatistic(LocalDate beginCreateTime, LocalDate endCreateTime) {
        Set salesVOS = indexService.getSalesStatistic(beginCreateTime, endCreateTime);
        return Result.success(salesVOS);
    }

    @GetMapping("/businessChangeStatistics")
    public Result getBusinessStatistic(LocalDate beginCreateTime, LocalDate endCreateTime) {
        return indexService.getBusinessStatistic(beginCreateTime, endCreateTime);
    }

}
